import 'package:flutter/material.dart';
import 'package:view_lamp/custom/light_string_preview.dart';
import 'custom/preview_action_script.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    TextStyle sty = TextStyle(fontSize: 16, color: Colors.white);
    return Scaffold(
      appBar: AppBar(
        title: Text('预览效果', style: sty),
        backgroundColor: Colors.black,
        centerTitle: true,
      ),
      backgroundColor: Colors.grey[700],
      body: ListView(shrinkWrap: true, children: [
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 10),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text('1.异步随机跳变', style: sty),
              LightStringPreview(
                RandomAsyncScript([
                  0xFFFF0000,
                  0xFF00FF00,
                  0xFF0000FF,
                  0xFFFFFF00,
                  0xFF00FFFF,
                  0xFFFF00FF,
                ]),
              ),
              Text('2.异步随机渐变', style: sty),
              LightStringPreview(
                RandomAsyncScript([
                  0xFFFF0000,
                  0xFF00FF00,
                  0xFF0000FF,
                  0xFFFFFF00,
                  0xFF00FFFF,
                  0xFFFF00FF,
                ],transformDuration: Duration(milliseconds: 500)),
              ),
              Text('3.填充模式 红，绿', style: sty),
              LightStringPreview(
                  SingleColorFillScript(Color(0xFFFF0000), Color(0xFF00FF00))),
              Text('4.星星闪烁', style: sty),
              LightStringPreview(
                StarsTwinkleScript([
                  0xFFFF0000,
                  0xFF000000,
                ]),
              ),
              Text('5.对闪模式', style: sty),
              LightStringPreview(
                MutualFlashScript([
                  0xFFFF0000,
                  0xFF00FF00,
                ]),
              ),
              Text('6.波浪模式', style: sty),
              LightStringPreview(
                WaveScript(
                  [
                    0xFFFF0000,
                  ],
                  [
                    0xFFFF0000,
                    0xFF00FF00,
                    0xFF0000FF,
                    0xFFFFFF00,
                    0xFF00FFFF,
                    0xFFFF00FF,
                  ],
                  duration: Duration(milliseconds: 1500),
                  transformDuration: Duration(milliseconds: 500)
                ),
              ),
              Text('7.同步呼吸', style: sty),
              LightStringPreview(
                SynchronizedBreathScript(
                  [
                    0xFFFF0000,
                    0xFF00FF00,
                    0xFF0000FF,
                    0xFFFFFF00,
                    0xFF00FFFF,
                    0xFFFF00FF,
                  ],
                  duration: Duration(milliseconds: 1500),
                  transformDuration: Duration(milliseconds: 500)
                ),
              ),
              Text('8.填充模式并还原', style: sty),
              LightStringPreview(SingleColorFillScript(
                  Color(0xFF00FF00), Color(0xFFFF0000),
                  needReturn: true)),
              Text('9.爆闪模式', style: sty),
              LightStringPreview(
                StrobeScript(
                  [
                    0xFF0000FF,
                    0xFF00FF00,
                  ],
                  [
                    0xFFFF0000,
                    0xFF00FF00,
                    0xFF0000FF,
                    0xFFFFFF00,
                    0xFF00FFFF,
                    0xFFFF00FF,
                  ],
                ),
              ),
              Text('10.同步频闪', style: sty),
              LightStringPreview(
                SynchronousStrobeScript(
                  [
                    0xFFFF0000,
                    0xFF00FF00,
                    0xFF0000FF,
                    0xFFFFFF00,
                    0xFF00FFFF,
                    0xFFFF00FF,
                  ],
                  duration: Duration(milliseconds: 400),
                ),
              ),
              Text('11.同步跳变', style: sty),
              LightStringPreview(
                SynchronousJumpScript(
                  [0xFFFF0000,
                    0xFF00FF00,
                    0xFF0000FF,
                    0xFFFFFF00,
                    0xFF00FFFF,
                    0xFFFF00FF,],
                ),
              ),
              // Text('12.跳变', style: sty),
              // LightStringPreview(
              //   JumpScript(
              //     [
              //       0xFFFFFF00,
              //       0xFF00FFFF,
              //       0xFFFF00FF,
              //       0xFFFF0000,
              //       0xFF00FF00,
              //       0xFF0000FF,
              //     ],
              //   ),
              //   duration: Duration(milliseconds: 400),
              // ),
              Text('13.七彩', style: sty),
              LightStringPreview(
                MultiScript([
                  WaveScript(
                      [
                        0xFFFF0000,
                      ],
                      [
                        0xFFFF0000,
                        0xFF00FF00,
                        0xFF0000FF,
                        0xFFFFFF00,
                        0xFF00FFFF,
                        0xFFFF00FF,
                      ],
                      duration: Duration(milliseconds: 1500),
                      transformDuration: Duration(milliseconds: 500)
                  ),
                  SynchronizedBreathScript(
                      [
                        0xFFFF0000,
                        0xFF00FF00,
                        0xFF0000FF,
                        0xFFFFFF00,
                        0xFF00FFFF,
                        0xFFFF00FF,
                      ],
                      duration: Duration(milliseconds: 1500),
                      transformDuration: Duration(milliseconds: 500)
                  ),
                  SynchronousStrobeScript(
                    [
                      0xFFFF0000,
                      0xFF00FF00,
                      0xFF0000FF,
                      0xFFFFFF00,
                      0xFF00FFFF,
                      0xFFFF00FF,
                    ],
                  ),
                  SynchronousJumpScript(
                    [
                      0xFFFFFF00,
                      0xFF00FFFF,
                      0xFFFF00FF,
                      0xFFFF0000,
                      0xFF00FF00,
                      0xFF0000FF,
                    ],
                  )
                ])
              ),
              Text('14.叠加模式', style: sty),
              LightStringPreview(
                SuperimposeScript(
                  [
                    0xFFFF0000,
                    0xFF00FF00,
                    0xFF0000FF,
                    0xFFFFFF00,
                    0xFF00FFFF,
                    0xFFFF00FF,
                  ],
                ),
              ),
            ],
          ),
        )
      ]),
    );
  }
}
